package com.wx.demo.enhancer;

import net.bytebuddy.asm.Advice;

import java.util.Objects;

public class MyAdvice {
    //方法进入时
    @Advice.OnMethodEnter
    static long enter(@Advice.AllArguments Object[] ary) {
        if (Objects.nonNull(ary)) {
            for (int i = 0; i < ary.length; i++) {
                System.out.println("参数" + i + "内容：" + ary[i]);
            }
        }
        return System.nanoTime();
    }
    //方法退出时
    @Advice.OnMethodExit
    static void exit(@Advice.Enter long value) {
        System.out.println("耗时为" + (System.nanoTime() - value) + "纳秒");
    }
}
